package com.example.administrator.hello.AndroidText;

import android.support.test.uiautomator.By;
import android.support.test.uiautomator.UiDevice;
import android.support.test.uiautomator.UiObject2;
import android.support.test.uiautomator.Until;

/**对常见定位方式进行封装
 * Created by Administrator on 2017/7/15.
 */

public class Finder {
    private UiDevice device;

    public Finder(UiDevice device){
        this.device = device;
    }

    public UiObject2 findById(String id){
        device.wait(Until.hasObject(By.res(id)),
                10000);
        return device.findObject(By.res(id));
    }

    public UiObject2 findById(String id,int index){
        device.wait(Until.hasObject(By.res(id)),
                10000);
        return device.findObjects(By.res(id)).get(index);
    }

}
